
************************************************************************************************
************SSQ, Widestrom, Hayes, Dennis*******************************************************
*Replication Data for: The Effect of Political Parties *****************************************
*on the Distribution of Income in the American States: 1917–2011********************************
************************************************************************************************

xtset stnum year, yearly
*NOTE: you need to download fracdiff (in command line type: ssc install fracdiff)

***create gini_frank*100
gen gini_frank1=gini_frank*100

****dropping AK, HI, NE, MN
drop if stnum==2
drop if stnum==11
drop if stnum==23
drop if stnum==27
set more off

*******ipolate missing years of 1983-85 for top 1 variable
for num 1/56: ipolate nt1 year if stnum==X, gen(newtop1_5X)
gen newtop1i=newtop1_51 if stnum==1
for num 2/56: replace newtop1i=newtop1_5X if stnum==X
drop newtop1_51

*******ipolate missing years of 1983-85 for top 5 variable
for num 1/56: ipolate nt95100 year if stnum==X, gen(newtop5_5X)
gen newtop5i=newtop5_51 if stnum==1
for num 2/56: replace newtop5i=newtop5_5X if stnum==X
drop newtop5_51

*******ipolate missing years of 1983-85 for top 1 variable
for num 1/56: ipolate nthalf year if stnum==X, gen(newth_5X)
gen newthi=newth_51 if stnum==1
for num 2/56: replace newthi=newth_5X if stnum==X
drop newth_51

*******ipolate missing years of 1983-85 for aveinc variable
for num 1/56: ipolate aveinc year if stnum==X, gen(aveinc_5X)
gen aveinc1=aveinc_51 if stnum==1
for num 2/56: replace aveinc1=aveinc_5X if stnum==X
drop aveinc_51

***rescale wage variable for 
gen aveinc2=aveinc1/1000
gen aveincus1=aveincus/1000

gen pcdinc1=pcdinc/1000
gen pcdinc1us=pcdincus/1000


****gen time period variables to ttest for differences*****
gen period1v2=.
replace period1v2=1 if year >= 1917 & year <= 1947
replace period1v2=0 if year >= 1948
tab period1v2

gen period2v3=.
replace period2v3=1 if year >= 1948 & year <= 1977
replace period2v3=0 if year >= 1917 & year <=1947 | year >= 1978 & year <= 2011
tab period2v3

gen period1v3=.
replace period1v3=1 if year >= 1978 & year <= 2011
replace period1v3=0 if year <=1977 & year >= 1917
tab period1v3


ttest newtop1i, by(period1v2)
ttest newtop1i, by(period2v3)
ttest newtop1i, by(period1v3)

****generate new polarizaiton measure
gen newpolar=rsmeandwn-dsmeandwn
sum newpolar

******figure 1*****
graph box newtop1i if year>=1917 & year<2011, over(year) title("") nooutsides scheme(s1mono)

***TABLE 1 - P.903********
eststo clear
xtpmg d.newtop1i d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1917 & year <= 2011, lr(l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop) dfe cluster(stnum) replace
est sto m1
xtpmg d.newtop1i d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1917 & year <= 1947, lr(l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop) dfe cluster(stnum) replace
est sto m2
xtpmg d.newtop1i d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1948 & year <= 1977, lr(l.newtop1i l.produce l.repcont l.demcont l.repcontn l.polars l.aveinc2 l.demcontn l.afapop l.latpop) dfe cluster(stnum) replace
est sto m3
xtpmg d.newtop1i d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1978 & year <= 2011, lr(l.newtop1i l.produce l.repcont l.demcont l.repcontn l.polars l.aveinc2 l.demcontn l.afapop l.latpop) dfe cluster(stnum) replace
est sto m4
esttab m1 m2 m3 m4, se replace stats(r2 r2_a r2_p aic bic N  ll cmd) starlevels(* .10 ** .05 *** .01) 



****unit root test, http://www.stata.com/features/overview/panel-data-unit-root-tests/

xtunitroot ht newtop1i 

*fracdiff newtop1i repcontn


***generate interactions between polarization and party control*****
gen demcontn_polarh=demcontn*polarh
gen repcontn_polarh=repcontn*polarh

gen demcontn_polarh1=demcontn*l.polarh
gen repcontn_polarh1=repcontn*l.polarh

gen demcontn_polarh2=l.demcontn*l.polarh
gen repcontn_polarh2=l.repcontn*l.polarh

***interaction with senate polarization
gen demcontn_polars=demcontn*polars
gen repcontn_polars=repcontn*polars

gen demcontn_polars1=demcontn*l.polars
gen repcontn_polars1=repcontn*l.polars


gen demcontn_polars2=l.demcontn*l.polars
gen repcontn_polars2=l.repcontn*l.polars

gen demcontn_polars3=d.demcontn*d.polars
gen repcontn_polars3=d.repcontn*d.polars


***Table A2 - P. 907 - There ae some inaccuracies in this table. Since the years of the study are from 1917 to 2010 the results in the next command are for that time period.  This is different than the results in Table A2.  In some cases the results in Table A2 are based on a longer time period than the period of the analysis.  For example, the mean percentage of a state's population who are African-American is listed in Table A2 as 10.2%.  That figure is for the 1890-2010 period. For the 1917-2010 period the percentage is 9.87%.  Additionally, the 1917-2010 mean for productivity is 27.01 rather than the 22.1 figure in Table A2. The figure for the real wage (rahwage) is very different from that reported in Table A2 (17.48 instead of .29).  Also the figures for unified state party control (demcont and repcont) and unified national party control (demcontn and repcontn) appear, in some cases, to be reversed and/or based on a longer time period than the period of analysis. Over the 1917-2010 period the correct means are as follows: unified Republican control at the state level - .25, unified Democratic control at the state level - .35, unified Republican control at the national level - .21 and unified Democratic control at the national level .36. Similarily, the mean for senate polarization over the 1917-2010 period is .53 rather than .60 as reported in Table A2.    

summarize newtop1i produce rahwage aveinc repcont demcont repcontn demcontn polars latpop afapop union mood unemp if year>1916 & year<2011


***APPENDIX B: ALTERNATIVE MODEL SPECIFICATIONS

***Table B1 - Dynamic Fixed Effects Error Correction Models - Pages 907-908
xtpmg d.newtop1i d.produce d.aveinc2 d.repcont d.demcont d.repcontn d.demcontn d.polars d.afapop d.latpop d.union d.mood d.unemploy if year >= 1978 & year <= 2011, lr(l.newtop1i l.produce l.aveinc2 l.repcont l.demcont l.repcontn l.demcontn l.polars l.afapop l.union l.latpop l.mood l.unemploy) dfe cluster(stnum) replace
est sto m5
xtpmg d.newtop1i d.produce d.aveinc2 d.repcont d.demcont d.repcontn d.demcontn d.polars d.afapop d.latpop d.union d.mood d.unemploy if year >= 1978 & year <= 2011, lr(l.newtop1i l.produce l.aveinc2 l.repcont l.demcont l.repcontn l.demcontn l.polars l.afapop l.union l.latpop l.mood l.unemploy demcontn_polars3 repcontn_polars3) dfe cluster(stnum) replace
est sto m6
esttab m5 m6, se replace stats(r2 r2_a r2_p aic bic N  ll cmd) starlevels(* .10 ** .05 *** .01) 

***Table B2 - Fixed Effects Regression

xtreg l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop if year >= 1917 & year <= 2011,  fe vce(cluster stnum)
est sto m7
xtreg l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop if year >= 1917 & year <= 1947,  fe vce(cluster stnum)
est sto m8
xtreg l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop if year >= 1948 & year <= 1977,  fe vce(cluster stnum)
est sto m9
xtreg l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop if year >= 1978 & year <= 2011,  fe vce(cluster stnum)
est sto m10
esttab m7 m8 m9 m10, se replace stats(r2 r2_a r2_p aic bic N  ll cmd) starlevels(* .10 ** .05 *** .01) 

***Table B3 - Dynamic Fixed Effects Error Correction Models (Strongly Balanced Panels) for Top 0.5 Percent
xtpmg d.newthi d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1917 & year <= 2011, lr(l.newthi l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop) dfe cluster(stnum) replace
est sto m11
xtpmg d.newthi d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1917 & year <= 1947, lr(l.newthi l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop) dfe cluster(stnum) replace
est sto m12
xtpmg d.newthi d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1948 & year <= 1977, lr(l.newthi l.produce l.repcont l.demcont l.repcontn l.polars l.aveinc2 l.demcontn l.afapop l.latpop) dfe cluster(stnum) replace
est sto m13
xtpmg d.newthi d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1978 & year <= 2011, lr(l.newthi l.produce l.repcont l.demcont l.repcontn l.polars l.aveinc2 l.demcontn l.afapop l.latpop) dfe cluster(stnum) replace
est sto m14
esttab m11 m12 m13 m14, se replace stats(r2 r2_a r2_p aic bic N  ll cmd) starlevels(* .10 ** .05 *** .01) 

***Table B4 -  Dynamic Fixed Effects Error Correction Models (Strongly Balanced Panels) for Top 5 Percent - 
xtpmg d.ftop5 d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1917 & year <= 2011, lr(l.ftop5 l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop) dfe cluster(stnum) replace
est sto m15
xtpmg d.ftop5 d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1917 & year <= 1947, lr(l.ftop5 l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop) dfe cluster(stnum) replace
est sto m16
xtpmg d.ftop5 d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1948 & year <= 1977, lr(l.ftop5 l.produce l.repcont l.demcont l.repcontn l.polars l.aveinc2 l.demcontn l.afapop l.latpop) dfe cluster(stnum) replace
est sto m17
xtpmg d.ftop5 d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop if year >= 1978 & year <= 2011, lr(l.ftop5 l.produce l.repcont l.demcont l.repcontn l.polars l.aveinc2 l.demcontn l.afapop l.latpop) dfe cluster(stnum) replace
est sto m18
esttab m15 m16 m17 m18, se replace stats(r2 r2_a r2_p aic bic N  ll cmd) starlevels(* .10 ** .05 *** .01) 

***APPENDIX C - Dynamic Fixed Effects Error Correction Models (Strongly Balanced Panels): Interaction Between Federal Party Contro and Polarization 

xtpmg d.newtop1i d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop demcontn_polars3 repcontn_polars3 if year >= 1917 & year <= 2011, lr(l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop demcontn_polars2 repcontn_polars2) dfe cluster(stnum) replace
est sto m19
xtpmg d.newtop1i d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop demcontn_polars3 repcontn_polars3 if year >= 1917 & year <= 1947, lr(l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop demcontn_polars2 repcontn_polars2) dfe cluster(stnum) replace
est sto m20
xtpmg d.newtop1i d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop demcontn_polars3 repcontn_polars3 if year >= 1948 & year <= 1977, lr(l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop demcontn_polars2 repcontn_polars2) dfe cluster(stnum) replace
est sto m21
xtpmg d.newtop1i d.produce d.repcont d.demcont d.repcontn d.demcontn d.polars d.aveinc2 d.afapop d.latpop demcontn_polars3 repcontn_polars3 if year >= 1978 & year <= 2011, lr(l.newtop1i l.produce l.repcont l.demcont l.repcontn l.demcontn l.polars l.aveinc2 l.afapop l.latpop demcontn_polars2 repcontn_polars2) dfe cluster(stnum) replace
est sto m22
esttab m19 m20 m21 m22, se replace stats(r2 r2_a r2_p aic bic N  ll cmd) starlevels(* .10 ** .05 *** .01) 









